/* A button that is able to be selected
 * 
 */

package gui.utilities;

import java.awt.event.*;

import javax.swing.*;

public class MySelectableButton extends MyButton{

	private static final long serialVersionUID = -6470790231659884341L;
	private JLabel select; //the path to the selected icon
	private boolean isSelected; //if the button is selected
	
	//the super constructor to set up the button
	private MySelectableButton(String n, String o, int w, int h) {
		super(n, o, w, h);
	}//the super constructor

	
	//5 param constructor to set up the button
	public MySelectableButton(String n ,String o, String s, int w, int h){
		
		this(n, o, w, h);
		
		select = new JLabel(new ImageIcon(s));
		isSelected = false;
	}//String String String int int constructor
	
	
	//selects the button
	public void selectButton(){
		
		if(!isSelected){
		
			this.removeMouseListener(action);
			
			this.removeAll();
			this.add(select);
			this.repaint();
			this.revalidate();
			isSelected = true;
		}//if
	}//selectButton
	
	
	//deselects the button
	public void deselectButton(){
		if(isSelected){
		
			this.addMouseListener(action);
		
			this.removeAll();
			this.add(normal);
			this.repaint();
			this.revalidate();
			isSelected = false;
		}//if
	}//deselectButton
	
	
	//returns if the button is selected
	public boolean getSelected(){
		
		return isSelected;
	}//getSelected
}//MySelectable Button
